home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / virus / stelth22.zip / TESTVIR.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-10  |  4KB  |  154 lines

  1. {$I-}
  2. {
  3. testvir.pas
  4. Stealth Bomber Version 2.2
  5.  
  6. Kevin Dean
  7. Fairview Mall P.O. Box 55074
  8. 1800 Sheppard Avenue East
  9. Willowdale, Ontario
  10. CANADA    M2J 5B9
  11. CompuServe ID: 76336,3114
  12.  
  13. February 10, 1992
  14.  
  15.     This program demonstrates the anti-virus CRC algorithm in
  16. VIRCHECK.PAS.  The response to error codes is entirely up to the programmer.
  17.  
  18.     To set the CRC for this program and its supporting files, the command
  19. is:
  20.  
  21.     crcset -p testvir.exe vircheck.tpu -d crc.dat vircheck.pas
  22.  
  23.     This code is public domain.
  24. }
  25.  
  26.  
  27. program TestVIR;
  28.  
  29.  
  30. uses
  31.   DOS, VirCheck;
  32.  
  33.  
  34. const
  35.   FN : array [1 .. 3] of string[12] =
  36.     (
  37.     'TESTVIR.EXE', 'VIRCHECK.TPU', 'VIRCHECK.PAS'
  38.     );
  39.  
  40.   { Normally this would be defined by changing StealthNFiles in VIRUSDAT.PAS to
  41.     3; it has not been done that way for this program as this is a sample file
  42.     only. }
  43.   _FCRC : array [1 .. 3] of FileCRC =
  44.     (
  45.       (
  46.       SearchStr : ('_', 'S', 'T', 'E', 'A', 'L', 'T', 'H')
  47.       ),
  48.       (
  49.       SearchStr : (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ')
  50.       ),
  51.       (
  52.       SearchStr : (' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ')
  53.       )
  54.     );
  55.  
  56.  
  57. {$F+}
  58. {***}
  59. { Override default handling of memory allocation errors (see chapter 15 - Inside Turbo Pascal). }
  60. function HeapFunc(Size : word) : integer;
  61.  
  62. begin
  63. HeapFunc := 1;
  64. end;
  65. {$F-}
  66.  
  67.  
  68. var
  69.   SysResult : word;
  70.   FileResult : word;
  71.   ErrFound : boolean;
  72.   CRCFile : file of FileCRC;
  73.   I : integer;
  74.  
  75.  
  76. begin
  77. HeapError := @HeapFunc;
  78.  
  79. ErrFound := false;
  80.  
  81. { Check system. }
  82. SysResult := StealthSysCheck;
  83.  
  84. if SysResult and StealthIntrErr <> 0 then
  85.   begin
  86.   WriteLn('System interrupts have been set beyond current code space.  This may indicate');
  87.   WriteLn('the presence of a virus in system memory.');
  88.   end;
  89. if SysResult and StealthDOSMemErr <> 0  then
  90.   begin
  91.   WriteLn('Memory reported by DOS is inconsistent with memory reported by BIOS.  This may');
  92.   WriteLn('inidicate the presence of a virus in system memory.');
  93.   end;
  94. if SysResult and StealthDOSHijacked <> 0  then
  95.   begin
  96.   WriteLn('A DOS interrupt has been covertly redirected by another program.  This may');
  97.   WriteLn('inidicate the presence of a virus in system memory.');
  98.   end;
  99. if SysResult <> StealthOK then
  100.   begin
  101.   WriteLn;
  102.   ErrFound := true;
  103.   end;
  104.  
  105. Assign(CRCFile, 'CRC.DAT');
  106. Reset(CRCFile);
  107. if IOResult = 0 then
  108.   begin
  109.   Read(CRCFile, _FCRC[3]);
  110.   Close(CRCFile);
  111.   end
  112. else
  113.   WriteLn('Error opening CRC.DAT file.');
  114.  
  115. for I := 1 to 3 do
  116.   begin
  117.   if (I <> 1) or (Lo(DOSVersion) < 3) then
  118.     FileResult := StealthFileCheck(FN[I], _FCRC[I])
  119.   else
  120.     FileResult := StealthFileCheck(ParamStr(0), _FCRC[I]);
  121.  
  122.   if FileResult and StealthFileErr <> 0  then
  123.     WriteLn('Error accessing ', FN[I], ' for CRC check.');
  124.   if FileResult and StealthFileDateErr <> 0 then
  125.     begin
  126.     WriteLn('Date stamp error on file ', FN[I], '.  This may indicate the presence of a');
  127.     WriteLn('virus in the file.  Please take appropriate steps to secure your computer from');
  128.     WriteLn('further possible infection.');
  129.     end;
  130.   if FileResult and StealthFileSizeErr <> 0  then
  131.     begin
  132.     WriteLn('File size error on file ', FN[I], '.  This may indicate the presence of a');
  133.     WriteLn('virus in the file.  Please take appropriate steps to secure your computer from');
  134.     WriteLn('further possible infection.');
  135.     end;
  136.   if FileResult and (StealthCRCBadPoly or StealthCRCInvalid) <> 0  then
  137.     begin
  138.     WriteLn('CRC error on file ', FN[I], '.  This file has been tampered with and may be');
  139.     WriteLn('infected by a computer virus.  Please take appropriate steps to secure your');
  140.     WriteLn('computer from further possible infection.');
  141.     end;
  142.   if FileResult and StealthNoMem <> 0  then
  143.     WriteLn('Insufficient memory to run CRC check on file ', FN[I], '.');
  144.   if FileResult <> 0 then
  145.     begin
  146.     WriteLn;
  147.     ErrFound := true;
  148.     end;
  149.   end;
  150.  
  151. if not ErrFound then
  152.   WriteLn('No viruses found.');
  153. end.
  154.